From aae6ed85b74a59fcaf27838862ba54e29d10e397 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Thu, 25 Oct 2018 16:06:56 -0500 Subject: [PATCH] Move configuration into __init__.py --- src/pgwui_common/__init__.py | 44 +++++++++++++++++++ src/pgwui_common/configure.py | 44 ------------------- tests/{test_configure.py => test___init__.py} | 4 +- 3 files changed, 46 insertions(+), 46 deletions(-) delete mode 100644 src/pgwui_common/configure.py rename tests/{test_configure.py => test___init__.py} (93%) diff --git a/src/pgwui_common/__init__.py b/src/pgwui_common/__init__.py index e69de29..504dad1 100644 --- a/src/pgwui_common/__init__.py +++ b/src/pgwui_common/__init__.py @@ -0,0 +1,44 @@ +# Copyright (C) 2018 The Meme Factory, Inc. http://www.meme.com/ + +# This file is part of PGWUI_Common. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . +# + +# Karl O. Pinc + +'''Provide a way to configure PGWUI. + +To use pgwui_common configure your pyramid app by putting the +following into your package's __init__.py: + + from pyramid.config import Configurator + + def main(global_config, **settings): + config = Configurator() + config.include('pgwui_common') + +Note that you can override any of the assets in this package or any of +the PGWUI packages, any of the templates or css, using Pyramid's Asset +Override API (or via pyramid.includes = yourextension in the .ini file). + +''' + + +def includeme(config): + config.include('pyramid_mako') + config.include('pyramid_beaker') + config.add_static_view( + 'static', 'pgwui_common:/static', cache_max_age=3600) diff --git a/src/pgwui_common/configure.py b/src/pgwui_common/configure.py deleted file mode 100644 index d8103a8..0000000 --- a/src/pgwui_common/configure.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2018 The Meme Factory, Inc. http://www.meme.com/ - -# This file is part of PGWUI_Common. -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -# - -# Karl O. Pinc - -'''Provide a way to configure PGWUI. - -To use pgwui_common configure your pyramid app by putting the -following into your package's __init__.py: - - from pyramid.config import Configurator - - def main(global_config, **settings): - config = Configurator() - config.include('pgwui_common.configure.includeme') - -Note that you can override any of the assets in this package or any of -the PGWUI packages, any of the templates or css, using Pyramid's Asset -Override API (or via pyramid.includes = yourextension in the .ini file). - -''' - - -def includeme(config): - config.include('pyramid_mako') - config.include('pyramid_beaker') - config.add_static_view( - 'static', 'pgwui_common:/static', cache_max_age=3600) diff --git a/tests/test_configure.py b/tests/test___init__.py similarity index 93% rename from tests/test_configure.py rename to tests/test___init__.py index ca4eaa6..917efd6 100644 --- a/tests/test_configure.py +++ b/tests/test___init__.py @@ -19,7 +19,7 @@ # Karl O. Pinc -from pgwui_common import configure +import pgwui_common.__init__ as pgwui_common_init def test_configure_includecalled(): @@ -36,6 +36,6 @@ def test_configure_includecalled(): self.add_static_view_called = True config = MockConfig() - configure.includeme(config) + pgwui_common_init.includeme(config) assert config.include_called assert config.add_static_view_called -- 2.34.1